package main

import (
	"fmt"
	"math/rand"
	"strings"
)

/*
.........
*/

func MultiplyTable() {
	for i := 1; i < 10; i++ {
		for j := 1; j < i+1; j++ {
			fmt.Printf("%d*%d=%-4d", j, i, i*j)
			if i == j {
				fmt.Print("\n")
			}
		}
	}

	fmt.Println()
	for i := 1; i < 10; i++ {
		for j := i; j < 10; j++ {
			fmt.Printf("%d*%d=%-4d", i, j, i*j)
			if j == 9 {
				fmt.Print("\n")
				fmt.Print(strings.Repeat("        ", i))
			}
		}
	}
	fmt.Println()
}
func RandomTable() {
	fmt.Print("1-20的20个随机数中奇数之和为:")
	a, b := 0, 1
	for i := 0; i < 20; i++ {
		t := rand.Intn(20) + 1
		if t&1 == 1 {
			a += t
		} else {
			b *= t
		}
		fmt.Printf("%-4d", t)
	}
	fmt.Printf("\n1-20的20个随机数中奇数之和为%d，偶数之积为:%d\n", a, b)
}
func Fibonacci() {
	p_seed, s_seed := 1, 1
	fmt.Printf("100以内的斐波那契数列: ")
	fmt.Printf("%d %d ", p_seed, s_seed)
	for p_seed+s_seed < 100 {
		p_seed, s_seed = s_seed, p_seed+s_seed
		fmt.Printf("%d ", s_seed)
	}
}
func main() {

	MultiplyTable() //99乘法表
	RandomTable()   //1-20随机数
	Fibonacci()     //斐波那契数列

}
